import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import user from '@/moudlue/user.js'
import setting from '@/moudlue/setting.js'
export default new Vuex.Store({
  state: {
    num: 6,
    str: '姚',
    age: 18,
    list: [1, 2, 3, 4, 5, 6, 7, 8, 9]
  },
  mutations: {
    change (state, obj) {
      console.log(state);
      state.num += obj.n
    },
    dingshiqi (state, mm) {
      state.age += mm
    }
  },
  actions: {
    actionsyibu (str, mm) {
      setTimeout(() => {
        // console.log(str,11111);
        console.log('我是姚锦坤');
        str.commit('dingshiqi', mm)
      }, 2000)
    }
  },
  getters: {
    total (state) {
      return state.list.reduce((item, num) => {
       return item += num
      }, 0)
    }
  },
  modules: {
    user,
    setting
  }
})
